﻿#include <stdio.h>

//main38：字符串添加拼接
int main38(void)
{
	char arr1[] = "hello";//01234  {'h','e','l','l','o','\0'}
	char arr2[] = "world";
	char arrBuf[100];//'\0'

	int index = 0;
	while (arr1[index] != '\0')
	{
		//1.将非\0的字符添加到arrBuf数组中；
		arrBuf[index] = arr1[index];
		//2.计数器增长；
		index++;
	}

	/*
	while (arr2[index - 5] != '\0')
	{
		arrBuf[index] = arr2[index - 5];
		index++;
	}
	*/
	int sIndex = 0;
	while (arr2[sIndex] != '\0')
	{
		arrBuf[index + sIndex] = arr2[sIndex];
		sIndex++;
	}
	//3.添加字符串结束标志\0；
	//arrBuf[index] = '\0';
	arrBuf[index + sIndex] = '\0';
	printf("4.输出拼接后的字符数组arrBuf：%s", arrBuf);//4.输出拼接后的字符数组arrBuf：helloworld
	return 0;
}